import { GET_MENU_COLLAPSE, SET_MENU_COLLAPSE, MENU_COLLAPSE_ACTION, STORAGE_MENU_COLLAPSE } from '@/utils/Const';
import Storage from '@/utils/Storage';
import { Commit } from 'vuex';

interface State {
  value: boolean
}
export default {
  namespaced: true,
  state: {
    value: Storage.get(STORAGE_MENU_COLLAPSE, 1) || false
  },
  getters: {
    [GET_MENU_COLLAPSE](state: State) {
      return state.value
    }
  },
  mutations: {
    [SET_MENU_COLLAPSE](state: State, payload: boolean) {
      state.value = payload;
      Storage.set(STORAGE_MENU_COLLAPSE, payload, 1);
    }
  },
  actions: {
    [MENU_COLLAPSE_ACTION](context: { commit: Commit }, payload: boolean) {
      context.commit(SET_MENU_COLLAPSE, payload);
    }
  }
}